package com.Iron.Config;

import com.Iron.Service.Impl.UserServiceImpl;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.stereotype.Component;


/*@Component*/
public class BeanManager implements BeanFactoryPostProcessor {
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("beanDefineMap填充后执行");

        BeanDefinition factoryBean1 = beanFactory.getBeanDefinition("FactoryBean1");

        System.out.println(factoryBean1.getBeanClassName());


    }
}

/*@Component*/
class BeanManager1 implements BeanDefinitionRegistryPostProcessor {

    //用于BeanDefinition的注册

    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
        RootBeanDefinition de = new RootBeanDefinition();
        de.setBeanClassName("com.Iron.Service.Impl.UserServiceImpl");
        registry.registerBeanDefinition("serviceTemp", de);
    }

    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

    }
}
